import { Component, ViewChild } from '@angular/core';
import { Events, AlertController, App, ModalController, NavController, Content, ActionSheetController} from 'ionic-angular';
import { MainService } from './main.service';
import { Storage } from '@ionic/storage';
import { Config } from '../../providers/config';
import {IrpReportInsideQueryPage} from '../query/insidequery/query.component';
import { DomSanitizer } from '@angular/platform-browser';
import _ from 'lodash';
import { Common } from "../../providers/common";
import { from } from 'rxjs/observable/from';

@Component({
  selector: 'irp-report-main-page',
  templateUrl: './main.html',
  providers: [MainService]
})
export class Irpreportmainpage {
  moa_page_name: any = "irp-report-main-page";
  moa_page_explain: any = "研报首页";
  

  type = "1";
  // 导航栏标题
  title = "研报首页";
 
  isFromMainPage = true;
  managerName = null;

  @ViewChild(Content) content: Content;

  constructor(
    public alertCtrl: AlertController,
    public app: App,
    public modalCtrl: ModalController,
    public navCtrl: NavController,
    public mainService: MainService,
   // public config: Config,
    private sanitizer: DomSanitizer,
    public events: Events,
    public storage: Storage,
    private actionSheetCtrl: ActionSheetController
   // private common: Common
  ) {
   
   }
  
  chooseReport() {
    var that = this;
    let actionSheet = this.actionSheetCtrl.create({
      buttons: [
        {
          text: "研报首页",
          handler: () => {
            that.title = "研报首页"
            that.type = '1';
          }
        },
        {
          text: "收藏",
          handler: () => {
            that.title = "收藏"
            that.type = '2';
          }
        },
        {
          text: "离开",
          role: 'cancel',
          handler: () => {
            
          }
        }
      ]
    });
    actionSheet.present();
  }

  showInsideAdvancedQueryModal(){
    let queryModal = this.modalCtrl.create(IrpReportInsideQueryPage, {
      
          });
          
          queryModal.present();
  }

  testSearch(){
    this.mainService.getIRMReport().subscribe((data) => {
       if(data){
         console.log(data);
       }
    });
   }
   
    
   }
